home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-06 | 6.5 KB | 222 lines | [TEXT/MMCC] |
- // ===========================================================================
- // NLMClientApp.cp
- // ===========================================================================
- //
- // This program works with the ATDemo NetWare NLM. It acts as the client
- // that makes a connection with the server and sends certain server
- // statistics requests.
- //
- // This program is NOT necessarily the model of good programming. The attention
- // has been spent on the server side. However, if you wish to use this
- // as a starter program, feel free.
- //
- // This program was written with Metrowerks C/C++ for 68k, using the
- // PowerPlant class hierarchy.
- //
- // It was written by Nick Brosnahan and Jamie Osborne. 9/94
- //
- // Apple Computer, Inc. makes no warranties about the the fitness of this code
- // for any purpose and will not be held liable for any damages you may suffer
- // from using this code. Furthermore, Apple Computer, Inc. will not be held
- // liable for the death of Elvis or any other space alien.
- //
- // Your mileage may vary.
-
- #pragma once
-
- #include "NLMClientApp.h"
- #include "LServerChooser.h"
- #include "LServerActions.h"
-
- #include <PP_Messages.h>
- #include <LApplication.h>
- #include <LGrowZone.h>
- #include <UMemoryMgr.h>
- #include <UDrawingState.h>
- #include <URegistrar.h>
- #include <UPowerTools.h>
-
- const ResIDT WIND_ServerChooser = 1000;
- const ResIDT WIND_ServerActions = 1001;
-
- const MessageT cmd_DoServerChooser = 1001;
- const MessageT cmd_DoServerActions = 1002;
-
- NLMClientApp *gApplication;
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- #ifdef Debug_Throw
- gDebugThrow = debugAction_Alert;
- #endif
-
- #ifdef Debug_Signal
- gDebugSignal = debugAction_Alert;
- #endif
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- #ifdef Debug_Signal // Check for missing MBAR, which
- CheckForInitialMBAR(); // probably means that there is no
- #endif // project resource file
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
- // Parameter is size of reserve memory
- // block to allocated. The first time
- // the GrowZone function is called,
- // there will be at least this much
- // memory left (so you'll have enough
- // memory to alert the user or finish
- // what you are doing).
-
- NLMClientApp theApp; // Create instance of your Application
- gApplication = &theApp;
- theApp.Run(); // class and run it
- }
-
-
- // ===========================================================================
- // • NLMClientApp Class
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • NLMClientApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- NLMClientApp::NLMClientApp()
- {
- // Register classes for objects created from 'PPob' resources
- // For PowerPlant classes, you can copy the necessary RegisterClass
- // calls from PPobClasses.cp
- //
- // For your own classes, you must use the same four-character ID as
- // you specify in the 'PPob' resource (or in Constructor).
- // PowerPlant reserves all ID's composed entirely of lower case
- // letters.
-
- URegistrar::RegisterClass('sact', (ClassCreatorFunc) LServerActions::CreateServerActionsStream);
- URegistrar::RegisterClass('scho', (ClassCreatorFunc) LServerChooser::CreateServerChooserStream);
- URegistrar::RegisterClass('lbox', (ClassCreatorFunc) LListBox::CreateListBoxStream);
- URegistrar::RegisterClass('pbut', (ClassCreatorFunc) LStdButton::CreateStdButtonStream);
- URegistrar::RegisterClass('capt', (ClassCreatorFunc) LCaption::CreateCaptionStream);
- URegistrar::RegisterClass('edit', (ClassCreatorFunc) LEditField::CreateEditFieldStream);
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~NLMClientApp
- // ---------------------------------------------------------------------------
- // Destructor
-
- NLMClientApp::~NLMClientApp()
- {
- // +++ Add code here to cleanup (if necessary) before quitting
- }
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- NLMClientApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the menu items for the commands
-
- case cmd_DoServerChooser:
- DoServerChooser();
- break;
-
- /* case cmd_DoServerActions:
- mServerActions->Show();
- break;
- */
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- NLMClientApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
- outEnabled = FALSE;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle.
- //
- // Set outEnabled to TRUE for commands that can be executed at
- // this time.
- //
- // If the associated menu items can have check marks, set
- // outUsesMark and outMark accordingly.
- //
- // Set outName to change the name of the menu item
-
- case cmd_DoServerChooser:
- // if (!mServerChooser->IsVisible())
- outEnabled = TRUE;
- break;
-
- case cmd_DoServerActions:
- // if ((!mServerChooser->IsVisible())&&(!mServerActions->IsVisible()))
- // outEnabled = TRUE;
- break;
-
- case cmd_Close:
- // if (mServerActions->IsVisible())
- // outEnabled = TRUE;
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }
-
- void NLMClientApp::DoServerChooser()
- {
- LServerChooser *serverChooser;
- serverChooser = (LServerChooser *)LServerChooser::CreateWindow(WIND_ServerChooser, this);
- serverChooser->DoSetupServerChooser();
-
- }
-